<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>宝石</title>
    <!--动态改变视口缩放比-->
    <script>
        var iScale = 1;
        iScale = iScale / window.devicePixelRatio;
        document.write('<meta name="viewport" content="width=device-width,user-scalable=no,' +
            'initial-scale=' + iScale + ',minimum-scale=' + iScale + ',maximum-scale=' + iScale + '">');
    </script>
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/swiper-3.4.2.min.css">
</head>
<body>
<div class="header">
    <a class="gobak" href="javascript :history.back(-1)" >
        <img  src="images/back.png" alt="">
    </a>
    注册
</div>
<div class="fixed1"></div>
<div class="banner">
    <div class="banner">
        <div class="swiper-container swiper-container1 ">
            <div class="swiper-wrapper">
                <div class="swiper-slide"><a href=""><img src="images/banner.jpg" alt=""></a></div>
                <div class="swiper-slide"><a href=""><img src="images/banner.jpg" alt=""></a></div>
                <div class="swiper-slide"><a href=""><img src="images/banner.jpg" alt=""></a></div>
            </div>
        </div>
    </div>
</div>
<div class="top_img">
    <img src="images/bkc.png" alt="">
</div>
<div class="input">
    <div class="under">
        <input type="text" class="admin" placeholder="请输入手机号">
        <div class="speil">
            <input type="text" class="pwd" placeholder="验证码码">
            <input id="btnSendCode" type="button" value="获取验证码" onClick="sendMessage()" />
        </div>
        <input type="text" class="pwd" placeholder="请填写密码">
    </div>
    <input type="button" class="submit" value="注册">
    <p>
        已注册？<a href="">请登录</a>
    </p>
</div>

<script type="text/javascript" src="js/jquery.min.js"></script>
<script src="js/swiper-3.4.2.min.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script>
        var InterValObj; //timer变量，控制时间
        var count = 30; //间隔函数，1秒执行
        var curCount;//当前剩余秒数
        var code = ""; //验证码
        var codeLength = 6;//验证码长度
        function sendMessage() {
            curCount = count;
            var dealType; //验证方式
            var uid=$("#uid").val();//用户uid
            if ($("#phone").attr("checked") == true) {
                dealType = "phone";
            }
            else {
                dealType = "email";
            }
//产生验证码
            for (var i = 0; i < codeLength; i++) {
                code += parseInt(Math.random() * 9).toString();
            }
//设置button效果，开始计时
            $("#btnSendCode").attr("disabled", "true");
            $("#btnSendCode").val( + curCount + "秒再获取");
            InterValObj = window.setInterval(SetRemainTime, 1000); //启动计时器，1秒执行一次
//向后台发送处理数据
           $.ajax({
                type: "POST", //用POST方式传输
                dataType: "text", //数据格式:JSON
                url: '', //目标地址
                data: "dealType=" + dealType +"&uid=" + uid + "&code=" + code,
                error: function (XMLHttpRequest, textStatus, errorThrown) { },
                success: function (msg){ }
            });
        }
//timer处理函数
        function SetRemainTime() {
            if (curCount == 0) {
                window.clearInterval(InterValObj);//停止计时器
                $("#btnSendCode").removeAttr("disabled");//启用按钮
                $("#btnSendCode").val("重新发送验证码");
                code = ""; //清除验证码。如果不清除，过时间后，输入收到的验证码依然有效
            }
            else {
                curCount--;
                $("#btnSendCode").val( + curCount + "秒再获取");
            }
        }
</script>
</body>
</html>